package com.grsu.phonestation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.grsu.phonestation.dao.PaymentDAO;
import com.grsu.phonestation.domain.Client;
import com.grsu.phonestation.domain.Payment;
import com.grsu.phonestation.service.PaymentService;

@Service
@Transactional
public class PaymentServiceImpl <P extends Payment> implements PaymentService<P> {


	@Autowired
	@Qualifier("paymentDAOImpl")
	private PaymentDAO<P> paymentDAO;
	
	@Override
	public void addPayment(P payment) {
		paymentDAO.save(payment);

	}

	@Override
	public void removePayment(int pymentId) {
		paymentDAO.remove(pymentId);

	}

	@Override
	public P getPaymentById(int pymentId) {
		P promisedPayment = paymentDAO.findById(pymentId);
		return promisedPayment;
	}

	@Override
	public List<P> getPaymentsClient(Client client){
		return paymentDAO.getPaymentClient(client);
		
	}
	
	@Override
	public List<P> listPayment() {
		List<P> payments = paymentDAO.findAll();
		return payments;
	}

}
